package com.gnkexy.springframework.core.io;

import java.io.InputStream;

/**
 * 类路径资源
 */

public class ClassPathResource implements Resource {

    private final String path;

    private ClassLoader classLoader;

    public ClassPathResource(String path){
        this(path,ClassLoader.getSystemClassLoader());
    }

    public ClassPathResource(String path, ClassLoader classLoader) {
        this.path = path;
        this.classLoader = classLoader;
    }

    @Override
    public InputStream getInputSteam() {
        InputStream is = classLoader.getResourceAsStream(path);
        if(is !=null){
            return is;
        }
        return null;
    }
}
